# Maintainer: Brett Cornwall <ainola@archlinux.org>
# Contributor: Dimitrios Vogiatzis
# Contributor: physkets
# Contributor: Justin Dray
# Contributor: Bill Kolokithas

pkgname=j4-dmenu-desktop
pkgver=2.18
pkgrel=4
pkgdesc="Find .desktop files and offer you a menu to start an application using dmenu"
arch=('loong64' 'x86_64')
url="https://github.com/enkore/j4-dmenu-desktop"
license=('GPL3')
optdepends=('dmenu: The default backend'
            'bemenu: An alternative backend')
makedepends=(
    'cmake'
    'git'  # For cloning "catch"; upstream doesn't use a system installation
)
options=('debug')
source=("$pkgname-$pkgver.tar.gz::$url/archive/r$pkgver.tar.gz"
        "$pkgname-$pkgver.tar.gz.sig::$url/releases/download/r$pkgver/r$pkgver.tar.gz.sig")
validpgpkeys=('A1774C1B37DC1DCEDB65EE469B8450B91D1362C1')  # Marian Beermann <public@enkore.de>
sha256sums=('77c5605d0c1291bcf1e13b186ea3b32ddf4753de0d0e39127b4a7d2098393e25'
            'SKIP')


build() {
    cmake -B build -S "$pkgname-r$pkgver" \
        -DCMAKE_BUILD_TYPE='None' \
        -DCMAKE_INSTALL_PREFIX='/usr'
    cmake --build build
}

check() {
    ctest --test-dir build --output-on-failure
}

package() {
    DESTDIR="$pkgdir" cmake --install build
    cd "$pkgname-r$pkgver"
    install -Dm0644 README.md -t "$pkgdir/usr/share/doc/$pkgname/"
    install -dm0755 "$pkgdir/usr/share/man/man1"
    gzip < j4-dmenu-desktop.1 > "$pkgdir/usr/share/man/man1/j4-dmenu-desktop.1.gz"
}

